//
//  NetworkTools.swift
//  LiveShow
//
//  Created by dai zhong on 2017/4/28.

//  Copyright © 2017年 company.cn. All rights reserved.
//

import UIKit
import Alamofire

enum MethodType {
    case get
    case post
}

class NetworkTools {

    public static func requestData(_ type :MethodType ,urlString:String ,parameters:[String :Any]? = nil ,finishedCallback: @escaping (_ result :Any) ->()){
    
        let method = type == MethodType.get ? HTTPMethod.get :HTTPMethod.post;

        Alamofire.request(urlString, method: method, parameters: parameters).responseJSON { (responseData) in
            
            guard let result = responseData.result.value else{
            
                print(responseData.error!)
                print(responseData.error!)
                return;
            }
            
            finishedCallback(result);
            
        }
    }
}
